<h2 class='page_title'>Calendrier</h2>

<div class='calendrier_mois'>
	<a class="prev" href="<? echo CFG_REP_INSTALL."calendrier"; ?>?ts=<? echo mktime(0,0,0,date("n",$ts)-1,1,date("Y",$ts)); ?>">Précédent</a>
	<p class="mois"><?php echo util_getMois(date("n",$ts)); ?></p>
	<a class="next" href="<? echo CFG_REP_INSTALL."calendrier"; ?>?ts=<? echo mktime(0,0,0,date("n",$ts)+1,1,date("Y",$ts)); ?>">Suivant</a>
</div>

<table id='calendrier' cellpadding="0" cellspacing="0">
	<tr>
		<td class="calendrier_jour_l">Lundi</td>
		<td class="calendrier_jour_l">Mardi</td>
		<td class="calendrier_jour_l">Mercredi</td>
		<td class="calendrier_jour_l">Jeudi</td>
		<td class="calendrier_jour_l">Vendredi</td>
		<td class="calendrier_jour_l">Samedi</td>
		<td class="calendrier_jour_l">Dimanche</td>
	</tr>
	<tr>
	<? $fin=0;
	$i=0;
	$nbj=0;
	for ($j=0;$j<$jour_deb;$j++){
		echo "<td><div class='calendrier_jour_off'></div></td>\n";
		$i++;
	}
	
			
	while($fin==0){
		$nbj++;

		$ts2=mktime(0,0,0,date("n",$ts),$nbj,date("Y",$ts));
		
		$events=getEvents($ts2);
		$s=sizeof($events);
		if($s==1) $size="64";
		elseif($s<=4) $size="30";
		else $size="18";
		
		?>
		<td>
			<div class="calendrier_jour">
				<? foreach($events as $event){ ?>
				<div class='calendrier_event_<? echo $size; ?>'><img src='<? echo $event->ico; ?>' style='width: <? echo $size; ?>px; height <? echo $size; ?>px;' onclick="window.open('<?php echo CFG_REP_INSTALL.$event->url; ?>','_self');" /></div>
				<? } ?>
				<div class="calendrier_jour_n"><? echo $nbj; ?></div>
			</div>
		</td>
		<?
		$i++;
		if(($i%7)==0) echo "</tr><tr>\n";
		if ($nbj==$nb_jours) $fin=1;
	}
	if(($i%7)>0){
		for($j=0;$j<(7-($i%7));$j++){
			echo "<td><div class='calendrier_jour_off'></td>\n";
		}
	}
	?>
	</tr>
</table>